function [x,y,typ]=mask_int(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
  constel=arg1.model.rpar(:);
  standard_draw(arg1)
case 'getinputs' then
  [x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
  [x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
  [x,y]=standard_origin(arg1)
case 'set' then
   x=arg1;
   graphics=arg1.graphics;model=arg1.model;
   exprs=graphics.exprs;

   while %t do

      [ok,M,herit,exprs]=getvalue('Set M-ASK modulator block',...
      ['Value of M:';'Inherit (no:0, yes:1)'],...
      list('vec',-1,'vec',1),exprs);

      if ~ok then break,end;
	  
	  M = round(M)
	  if M < 2 then
	  	message("Value of M is invalid")
	  	ok = %f
  	  end
	  constel = [-1: 2/(M-1): 1] * %i;
      //teste des points de la constellation
      if isreal(constel) then
        tt=find(size(constel)==2)
        if tt==[] then
          message('Set a complex vector of a matrix of size p,2 for constellation')
          ok=%F
        else
          if size(tt,'*')==1 then
            if tt==1 then
              constel=[constel(1,:)+%i*constel(2,:)]
            else
              constel=[constel(:,1)+%i*constel(:,2)]
            end
          else
             constel=[constel(:,1)+%i*constel(:,2)]
          end
        end
      end

      if ok then
         if herit==1 then
           model.dep_ut=[%t %f]
           [model,graphics,ok]=check_io(model,graphics,-1,[-1;-1],[],[])
         else
           model.dep_ut=[%f %f]
           [model,graphics,ok]=check_io(model,graphics,-1,[-1;-1],1,[])
         end
         graphics.id=[string(M)+" -ASK Modulator"];
         graphics.exprs=exprs;
         model.ipar=size(constel,'*');
         model.rpar=[real(constel(:));imag(constel(:))]
         x.graphics=graphics; x.model=model;
         break;
      end
   end

case 'define' then
  nb=4
  nu=-1
  M = 2;
  constel = [-1: 2/(M-1): 1] * %i;
  herit=1

  model=scicos_model()
  model.sim=list('modgen',4)
  model.in=nu
  model.out=[nu;nu]
  model.evtin=[]
  model.evtout=[]
  model.dstate=[]
  model.rpar=[real(constel(:));imag(constel(:))]
  model.ipar=size(constel,'*')
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%t %f]
  gr_i=['thick=xget(''thickness'')';
        'pat=xget(''pattern'')';
        'fnt=xget(''font'')';
        'ln_st=xget(""line style"")';
        'sz1=0.86*sz(1);sz2=0.86*sz(2)';
        'xxs=orig(1)+sz(1)/2';
        'yys=orig(2)+sz(2)/2';
        'nb=size(constel(:),''*'')/2';
        'if nb<16 then';
        '  ww=0.14*sz(1)';
        '  hh=0.14*sz(2)';
        'elseif nb>=32 then';
        '  ww=0.06*sz(1)';
        '  hh=0.06*sz(2)';
        'else';
        '  ww=0.1*sz(1)';
        '  hh=0.1*sz(2)';
        'end';
        'mmax=max([constel(:);imag(constel(:))])';
        'mmin=min([constel(:);imag(constel(:))])';
        'if(mmax>1)|(mmin<-1) then';
        '  aa_s=(mmax-mmin)/2';
        'else';
        '  aa_s=1';
        'end';
        'aa_s=aa_s/0.9';
        'aa1=0';
        'aa2=64*360';
        'xset(""line style"",2)';
        'xset(""line style"",ln_st)';
        'for ii=1:nb';
        '   xxx=xxs+sz1/2*constel(ii)/aa_s-ww/2';
        '   yyy=yys+sz2/2*constel(ii+nb(1))/aa_s+hh/2';
        '   xfarc(xxx,yyy,ww,hh,aa1,aa2)';
        'end';
        'xpoly([xxs;xxs],[orig(2);orig(2)+sz(2)],""lines"")';
        'xpoly([orig(1);orig(1)+sz(2)],[yys;yys],""lines"")';
        'xset(''thickness'',thick)';
        'xset(''pattern'',pat)';
        'xset(''font'',fnt(1),fnt(2))';]
  exprs=[string(M),string(herit)];
  x=standard_define([2 2],model,exprs,gr_i)
  x.graphics.id=["M-ASK Modulator"];
end
endfunction
